﻿using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;

namespace SWF
{
    public class With : IAction, IStackManipulator, IActionContainer
    {
        public ActionKind ActionId { get { return ActionKind.With; } }
        public uint Version { get { return 5; } }
        public uint Length
        {
            get
            {
                uint len = 3 + 2;
                len += (uint)WithBlock.Length + 1;
                return len;
            }
        }

        public uint StackPops { get { return 1; } }
        public uint StackPushes { get { return 0; } }
        public int StackChange { get { return -1; } }

        private uint codeSize;
        public uint CodeSize { get { return codeSize; } set { codeSize = value; } }
        private List<IAction> statements = new List<IAction>();
        public List<IAction> Statements { get { return statements; } }

        public uint Size
        {
            get
            {
                if (Statements == null) return 0;
                return (uint)Statements.Count;
            }
        }

        public string WithBlock;

        public List<IAction>[] ActionCollections
        {
            get
            {
                List<IAction>[] actions =
                    new List<IAction>[1] { Statements };
                return actions;
            }
        }

        public void Execute(Runtime.Clip clip, Stack<object> stack, Dictionary<string, object> variables, List<string> constantPool, Dictionary<string, List<IAction>> functionmap)
        {
        }
    }
}
